#ifndef RECTANGLE_H
#define RECTANGLE_H

#include "myshape.h"

class Rectangle : public MyShape
{
public:
    Rectangle(const QPointF &startPoint, const QPointF &endPoint, const QColor &color);

    QRectF boundingRect() const override;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;

    QPointF getEndPoint() const override { return endPoint_; }
    void setEndPoint(const QPointF &newEndPoint) override { endPoint_ = newEndPoint; }

    bool isPointNear(const QPointF &point) const override;
    void highlightControlPoints(const QPointF &point) override;

private:
    QPointF endPoint_;
    bool tlHighlighted_ = false;    // top-left
    bool trHighlighted_ = false;    // top-right
    bool blHighlighted_ = false;    // bottom-left
    bool brHighlighted_ = false;    // bottom-right
    bool edgeHighlighted_ = false;  // edge highlight

    QRectF rect() const;
    bool isPointNearEdge(const QPointF &point, const QRectF &rect) const;
};

#endif // RECTANGLE_H
